<?php
namespace app\app\controller\v1;
use think\Db;
class NavController extends  BaseController{

    /**
     * @return array
     * 口袋攻略
     */
    public function StrategyClass()
    {
        $data = Db::name('strategy_class')->where(['status'=>1])->select();
        return json_code(200,'success',$data);
    }

    /**
     * @return array
     * 全部攻略
     */
    public function StrategyList()
    {
        $a = Db::name('strategy')->alias('s')->join('strategy_class sc','s.class_id = sc.id','left')
            ->field('s.title,s.content,sc.class_name')
            ->where(['s.status'=>1,'s.class_id'=>1])->select();

        $b = Db::name('strategy')->alias('s')->join('strategy_class sc','s.class_id = sc.id','left')
            ->field('s.title,s.content,sc.class_name')
            ->where(['s.status'=>1,'s.class_id'=>2])->select();

        $c = Db::name('strategy')->alias('s')->join('strategy_class sc','s.class_id = sc.id','left')
            ->field('s.title,s.content,sc.class_name')
            ->where(['s.status'=>1,'s.class_id'=>3])->select();


        $d = Db::name('strategy')->alias('s')->join('strategy_class sc','s.class_id = sc.id','left')
            ->field('s.title,s.content,sc.class_name')
            ->where(['s.status'=>1,'s.class_id'=>4])->select();

        $e = Db::name('strategy')->alias('s')->join('strategy_class sc','s.class_id = sc.id','left')
            ->field('s.title,s.content,sc.class_name')
            ->where(['s.status'=>1,'s.class_id'=>5])->select();

        $f = Db::name('strategy')->alias('s')->join('strategy_class sc','s.class_id = sc.id','left')
            ->field('s.title,s.content,sc.class_name')
            ->where(['s.status'=>1,'s.class_id'=>6])->select();
        return json_code(200,'success',['a'=>$a,'b'=>$b,'c'=>$c,'d'=>$d,'e'=>$e,'f'=>$f]);
    }

    /**
     * 攻略分类展示
     */
    public function NavClassList()
    {
        $nav_class_id = input('get.nav_class_id');
        $nav = Db::name('nav')->where('nav_class_id',$nav_class_id)->select();
        return json_code(200,'success',$nav);
    }

    /**
     * 攻略内容展示
     */
    public function NavList()
    {
        $nav_id = input('get.nav_id');
        $data = Db::name('nav_content')->where('nav_id',$nav_id)->select();
        $nav = Db::name('nav')->find($nav_id);
        return json_code(200,'success',['nav'=>$nav['nav'],'data'=>$data]);
    }


}